﻿// HSS.Logging.LogCategory.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       LogCategory.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Logging
{
	#region Using Directives
	using System.Data;
	using System.Runtime.Serialization;
	using HSS.Data;
	#endregion

	#region LogCategory
	/// <summary>
	/// Contains the name and id of a Log Category.
	/// </summary>
	[DataContract]
	public class LogCategory : IDataContainer, IDataEntity
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public LogCategory()
		{

		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="dr">The <see cref="IDataRecord"/> to construct this instance from.</param>
		public LogCategory(IDataRecord dr)
		{
			this.Load(dr);
		}
		#endregion

		#region Object Model
		/// <summary>
		/// Gets or sets the Id value.
		/// </summary>
		[DataMember]
		public string Id
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		[DataMember]
		public string Name
		{
			get;
			set;
		}
		/// <summary>
		/// Gets this instance as an object.
		/// </summary>
		public object Data
		{
			get { return this; }
			set { }
		}
		#endregion

		#region IDataEntity Members
		/// <summary>
		/// Populates this instance from an <see cref="IDataRecord"/>.
		/// </summary>
		/// <param name="dr">The <see cref="IDataRecord"/> to populate this instance from.</param>
		public void Load(IDataRecord dr)
		{
			this.Id = dr.GetInt32(dr.GetOrdinal("CategoryId")).ToString();
			this.Name = dr.GetString(dr.GetOrdinal("Category"));
		}
		#endregion
	}
	#endregion
}